package com.google.android.exoplayer2.drm;

import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable.Creator;
import androidx.annotation.Nullable;
import com.google.android.exoplayer2.C;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.UUID;
import o.amm;
import o.anr;

public final class DrmInitData implements Comparator<SchemeData>, Parcelable {
    public static final Creator<DrmInitData> CREATOR = new Creator<DrmInitData>() {
        public /* synthetic */ Object createFromParcel(Parcel parcel) {
            return ॱ(parcel);
        }

        public /* synthetic */ Object[] newArray(int i) {
            return ˎ(i);
        }

        public DrmInitData ॱ(Parcel parcel) {
            return new DrmInitData(parcel);
        }

        public DrmInitData[] ˎ(int i) {
            return new DrmInitData[i];
        }
    };
    public final int ˊ;
    private final SchemeData[] ˋ;
    private int ˏ;
    @Nullable
    public final String ॱ;

    public static final class SchemeData implements Parcelable {
        public static final Creator<SchemeData> CREATOR = new Creator<SchemeData>() {
            public /* synthetic */ Object createFromParcel(Parcel parcel) {
                return ˋ(parcel);
            }

            public /* synthetic */ Object[] newArray(int i) {
                return ॱ(i);
            }

            public SchemeData ˋ(Parcel parcel) {
                return new SchemeData(parcel);
            }

            public SchemeData[] ॱ(int i) {
                return new SchemeData[i];
            }
        };
        private final UUID ʽ;
        private int ˊ;
        public final byte[] ˋ;
        @Nullable
        public final String ˎ;
        public final boolean ˏ;
        public final String ॱ;

        public SchemeData(UUID uuid, String str, byte[] bArr) {
            this(uuid, str, bArr, false);
        }

        public SchemeData(UUID uuid, String str, byte[] bArr, boolean z) {
            this(uuid, null, str, bArr, z);
        }

        public SchemeData(UUID uuid, @Nullable String str, String str2, byte[] bArr, boolean z) {
            this.ʽ = (UUID) amm.ॱ(uuid);
            this.ˎ = str;
            this.ॱ = (String) amm.ॱ(str2);
            this.ˋ = bArr;
            this.ˏ = z;
        }

        SchemeData(Parcel parcel) {
            this.ʽ = new UUID(parcel.readLong(), parcel.readLong());
            this.ˎ = parcel.readString();
            this.ॱ = parcel.readString();
            this.ˋ = parcel.createByteArray();
            this.ˏ = parcel.readByte() != (byte) 0;
        }

        public boolean ˏ(UUID uuid) {
            return C.ˏ.equals(this.ʽ) || uuid.equals(this.ʽ);
        }

        public boolean equals(@Nullable Object obj) {
            if (!(obj instanceof SchemeData)) {
                return false;
            }
            if (obj == this) {
                return true;
            }
            SchemeData schemeData = (SchemeData) obj;
            if (anr.ˎ(this.ˎ, schemeData.ˎ) && anr.ˎ(this.ॱ, schemeData.ॱ) && anr.ˎ(this.ʽ, schemeData.ʽ) && Arrays.equals(this.ˋ, schemeData.ˋ)) {
                return true;
            }
            return false;
        }

        public int hashCode() {
            if (this.ˊ == 0) {
                this.ˊ = (((((this.ˎ == null ? 0 : this.ˎ.hashCode()) + (this.ʽ.hashCode() * 31)) * 31) + this.ॱ.hashCode()) * 31) + Arrays.hashCode(this.ˋ);
            }
            return this.ˊ;
        }

        public int describeContents() {
            return 0;
        }

        public void writeToParcel(Parcel parcel, int i) {
            parcel.writeLong(this.ʽ.getMostSignificantBits());
            parcel.writeLong(this.ʽ.getLeastSignificantBits());
            parcel.writeString(this.ˎ);
            parcel.writeString(this.ॱ);
            parcel.writeByteArray(this.ˋ);
            parcel.writeByte((byte) (this.ˏ ? 1 : 0));
        }
    }

    public /* synthetic */ int compare(Object obj, Object obj2) {
        return ˊ((SchemeData) obj, (SchemeData) obj2);
    }

    public DrmInitData(List<SchemeData> list) {
        this(null, false, (SchemeData[]) list.toArray(new SchemeData[list.size()]));
    }

    public DrmInitData(SchemeData... schemeDataArr) {
        this(null, schemeDataArr);
    }

    public DrmInitData(@Nullable String str, SchemeData... schemeDataArr) {
        this(str, true, schemeDataArr);
    }

    private DrmInitData(@Nullable String str, boolean z, SchemeData... schemeDataArr) {
        SchemeData[] schemeDataArr2;
        this.ॱ = str;
        if (z) {
            schemeDataArr2 = (SchemeData[]) schemeDataArr.clone();
        } else {
            schemeDataArr2 = schemeDataArr;
        }
        Arrays.sort(schemeDataArr2, this);
        this.ˋ = schemeDataArr2;
        this.ˊ = schemeDataArr2.length;
    }

    DrmInitData(Parcel parcel) {
        this.ॱ = parcel.readString();
        this.ˋ = (SchemeData[]) parcel.createTypedArray(SchemeData.CREATOR);
        this.ˊ = this.ˋ.length;
    }

    public SchemeData ˎ(int i) {
        return this.ˋ[i];
    }

    public DrmInitData ˊ(@Nullable String str) {
        return anr.ˎ(this.ॱ, (Object) str) ? this : new DrmInitData(str, false, this.ˋ);
    }

    public int hashCode() {
        if (this.ˏ == 0) {
            this.ˏ = ((this.ॱ == null ? 0 : this.ॱ.hashCode()) * 31) + Arrays.hashCode(this.ˋ);
        }
        return this.ˏ;
    }

    public boolean equals(@Nullable Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null || getClass() != obj.getClass()) {
            return false;
        }
        DrmInitData drmInitData = (DrmInitData) obj;
        if (anr.ˎ(this.ॱ, drmInitData.ॱ) && Arrays.equals(this.ˋ, drmInitData.ˋ)) {
            return true;
        }
        return false;
    }

    public int ˊ(SchemeData schemeData, SchemeData schemeData2) {
        if (C.ˏ.equals(schemeData.ʽ)) {
            return C.ˏ.equals(schemeData2.ʽ) ? 0 : 1;
        } else {
            return schemeData.ʽ.compareTo(schemeData2.ʽ);
        }
    }

    public int describeContents() {
        return 0;
    }

    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeString(this.ॱ);
        parcel.writeTypedArray(this.ˋ, 0);
    }
}
